/*
 * main.cpp
 *
 *  Created on: 17-Mar-2010
 *      Author: nrqm
 */

#include "arduinomega/rtos/os.h"
#include "arduinomega/WProgram.h"
#include <avr/io.h>
#include <avr/interrupt.h>

extern "C" void __cxa_pure_virtual(){}

enum tasks
{
	BLINK=1,	// task 0 is IDLE
};

const unsigned char PPP[2] = { BLINK, 100};		// run periodic task every half second
const unsigned int PT = sizeof(PPP)/2;

void blink_pp()
{
	uint8_t led_on = 0;
	pinMode(13, OUTPUT);
	for (;;)
	{
		if (led_on)
		{
			digitalWrite(13, LOW);
			Serial.println("Blunk.");
		}
		else
		{
			digitalWrite(13, HIGH);
			Serial.println("Unblunk.");
		}
		led_on = !led_on;
		Task_Next();
	}
}

void r_main()
{
	init();
	Serial.begin(31250);
	Task_Create(blink_pp, 0, PERIODIC, BLINK);
}
